<%@ include file="connect.jsp" %>

<%
    String namaCat = request.getParameter("CatName");

    ResultSet rs = stat.executeQuery("Select * from CATEGORIES where lower(categoryName)=lower('" + namaCat + "') ");
    if (rs.next()) {
        response.sendRedirect("categories.jsp?respon=Category's name has exist, please choose another name!");

    } else {

        String sql = "INSERT INTO CATEGORIES (categoryName) values ('" + namaCat + "')";
        stat.executeUpdate(sql);

        response.sendRedirect("categories.jsp?respon=Category has been added!");
    }


    conn.close();

%>